


<template>
    <view class="docCommonScroll">
        <uni-popup :safe-area="false" background-color="#fff" style="flex:none" ref="popRef" type="right">
        <fl-popupfilter :notice="true" :urgency="false" @filter="filter" />
    </uni-popup>
    <fl-filterTabs @handleEmitChange="handleEmitChange" :statuss="statuss" :wait="wait" />
    <scroll-view @scrolltolower="scrolltolower" class="scroll-view" scroll-y>
        <uni-swipe-action v-if="list.length > 0">
            <uni-swipe-action-item v-for="(ele, index) in list" :key="index">
                <view @tap="handleReading(ele)" class="scroll_item">
                    <view class="right_content">
                        <view class="doc_title ellipsis">
                            {{ ele.bumphTheme }}
                        </view>
                        <view class="doc_date">
                            <text>{{ ele.issueUnit }}</text>
                            <text>{{ ele.deadline }}</text>
                        </view>
                    </view>
                </view>
                <template v-slot:right>
                    <!-- <view v-if="auth.hasPermi('bumph:inform:addUser') && ele.isComplete != 1 && ele.ifDo != 1" class="wander"
                        @tap="handleReading(ele)">阅办</view> -->
                    <!-- <view class="wander" v-if="auth.hasPermi('bumph:issue:addUser') && !(ele.isComplete != 1 && ele.ifDo != 1)"
                        @tap="handleWander(ele)">流转</view> -->
                    <!-- <view class="ending" v-if="auth.hasPermi('bumph:innerIssue:updateFinish') && ele.sendStatus == 1"
                        @tap="handleEnd(ele)">办结</view> -->
                    <!-- <view style="background: red;" class="Reading" v-if="ele.sendStatus == 3" @tap="handleRevoke(ele)">
                            撤销办结
                        </view> -->
                </template>
            </uni-swipe-action-item>
        </uni-swipe-action>
        <fl-empty v-else />
        <view style="padding: 10rpx 0;">
            <view class="none" v-if="isFinish">没有更多了~</view>
            <view class="loadMore" v-if="isMore">正在加载...</view>
        </view>

    </scroll-view>
    </view>

</template> 
<script setup lang="ts">
import { noticereceivingSublist,} from '@/api/http'
import { ref, nextTick, watch } from 'vue'
import auth from '@/plugins/auth'
const props = defineProps(['isRead', 'bumphTitle'])
const isFinish = ref(false)
const isMore = ref(false)
const list: any = ref([])
const popRef = ref()
const wait = ref(0)
const total = ref(0)
const par: any = {
    pageNum: 1,
    pageSize: 10,
    isComplete: 0,
}
const statuss = [
    { name: '未阅办', type: 0 },
    { name: '已阅办', type: 1 },
]
// onLoad(() => {
//     nextTick(() => {
//         getList()
//     })
// })

watch(() => props.isRead, (e) => {
    if (e) {
        reset()
    }
})
watch(() => props.bumphTitle, (newV) => {
    par.bumphTheme = newV
    nextTick(() => {
        reset()
    })
}, { immediate: true })


// const handleWander = (ele: any) => {
//     uni.navigateTo({
//         url: '/pages/wanderReceive/index?type=5&issueId='
//             + ele.issueId + '&issueOneId=' + ele.issueOneId

//     })
// }
const handleEmitChange = (t: number, type: number) => {
    switch (t) {
        case 1:
            popRef.value.open();
            break;
        case 2:
            delete par.isComplete
            reset()
            break;
        case 3:
            par.isComplete = type
            reset()
            break;
    }
}
const reset = () => {
    isFinish.value = false;
    isMore.value = false;
    par.pageNum = 1;
    list.value = [];
    total.value = 0;
    getList()
}
const getList = async () => {
    const res = await noticereceivingSublist(par)
    if (par.isComplete == 0) {
        wait.value = res.total
    }
    total.value = res.total
    list.value = [...list.value, ...res.rows]
}


const scrolltolower = () => {
    if (par.pageNum * par.pageSize >= total.value) {
        isFinish.value = true
        isMore.value = false
        return
    }
    par.pageNum += 1
    isMore.value = true
    getList()
}



const lookGw = (ele: any) => {
    if (!auth.hasPermi('bumph:inform:subQuery')) return
    uni.navigateTo({ url: '/pages/receiveToDetail/index?id=' + ele.informIssueOneId + '&type=3' })

}
// 去阅办 传递一个type参数区分一下
const handleReading = (ele: any) => {
    uni.navigateTo({
        url: '/pages/receiveToDetail/index?id=' + ele.issueOneId
            + '&type=4&ifRead='+ele.isComplete
    })
}

const filter = (e: any) => {
    const { date, status, t } = e
    //取消
    if (t == 0) return popRef.value.close()
    //确定
    if (date !== "") {
        par['params[beginTime]'] = e.date[0]
        par['params[endTime]'] = e.date[1]
    } else {
        delete par['params[beginTime]']
        delete par['params[endTime]']
    }
    // if (status != 0) {
    //     par.urgencyLevel = status
    // } else {
    //     delete par.urgencyLevel
    // }
    popRef.value.close()
    reset()


}

</script>


<style scoped lang="scss">





.scroll-view {
    flex: 1;
    height: 100%;
    overflow: hidden;
    background-color: #fff;

    .wander,
    .ending,
    .Reading {
        display: flex;
        align-items: center;
        width: 140rpx;
        justify-content: center;
        color: #fff;
        height: 100%;
        background-color: #0d80d7;
        font-size: 28rpx;
    }

    .ending {
        background-color: red;
    }

    .scroll_item {
        display: flex;
        width: 94%;
        margin: 0 auto;
        padding: 25rpx 0;
        min-height: 176rpx;
        // background-color: red;
        border-bottom: 2rpx solid #eeeeee;

        .left_status {
            width: 12%;

            .status_tips {
                color: #fff;
                font-size: 24rpx;
                padding: 2rpx 8rpx;
                border-radius: 9rpx;
            }
        }

        .right_content {
            flex: 1;

            .doc_title {
                font-size: 28rpx;
                color: #323233;
            }

            .doc_date {
                display: flex;
                justify-content: space-between;
                font-size: 28rpx;
                color: #999999;
                margin-top: 10rpx;
            }
        }
    }
}
</style>
